{extend name="layouts/cms"}
{block name='body-content'}
<form class="layui-form form-opArticle layui-form-pane">
    <div class="layui-form-item">
        <label class="layui-form-label">商品名称：</label>
        <div class="layui-input-inline">
            <input type="text" name="goods_name" required lay-verify="required"
                   value=""
                   placeholder="请输入商品名称" autocomplete="off" class="layui-input input-title-mz">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">缩略图片：</label>
        <div class="layui-upload layui-input-inline">
            <button type="button" name="img_upload" class="layui-btn btn_upload_img">
                <i class="layui-icon">&#xe67c;</i>上传图片
            </button>
            <img class="layui-upload-img img-upload-preview" src="">
        </div>
    </div>
    <input type="hidden" name="thumbnail" class="menu-icon" value="">
    <input type="hidden" name="slide_show" class="multiple-show-img" value="">
    <div class="layui-form-item">
        <label class="layui-form-label">轮播图片：</label>
        <div class="layui-upload">
            <button type="button" class="layui-btn" id="multiple-img-upload">多图片上传</button>
            <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                <div class="layui-upload-list" id="div-multiple-img-upload-preview"></div>
            </blockquote>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">提示语：</label>
        <div class="layui-input-inline">
            <input type="text" name="tip_word" required lay-verify="required"
                   value=""
                   placeholder="请输入购买提示语，一句话为宜" autocomplete="off" class="layui-input input-title-mz">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">状态：</label>
        <div class="layui-input-block">
            <input type="radio" name="status" value="0" title="下架" checked>
            <input type="radio" name="status" value="1" title="上架" checked>
            <input type="radio" name="status" value="-1" title="删除">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">参考价：</label>
        <div class="layui-input-inline">
            <input type="number" name="reference_price"
                   value="0" required lay-verify="required"
                   autocomplete="off" class="layui-input">
        </div>

        <label class="layui-form-label">售卖价：</label>
        <div class="layui-input-inline">
            <input type="number" name="selling_price"
                   value="0" required lay-verify="required"
                   autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">(价格,两位小数：12.50)</div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">排序：</label>
        <div class="layui-input-inline">
            <input type="number" name="list_order"
                   value="0" required lay-verify="required"
                   autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">(数字越大，排序越靠前)</div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">选择分类：</label>
        <div class="layui-input-inline">
            <select id="toSelCatID" lay-filter="toSelCatID" name="cat_id" lay-search="">
                <option value="">选择分类</option>
                {volist name="categoryList" id="cl"}
                <option value="{$cl.cat_id}">{$cl.cat_name}</option>
                {/volist}
            </select>
        </div>
        <label class="layui-form-label">添加属性：</label>
        <div class="layui-input-inline">
            <select id="toSelSpecFst" lay-filter="toSelSpecFst"
                    lay-verify="required" lay-search="">
                <option value="">直接选择或搜索选择</option>
            </select>
        </div>
    </div>
    <blockquote class="layui-elem-quote layui-quote-nm block-goods-sku" style="margin-top: 10px;">
        <button type="button" class="layui-btn layui-btn-normal">销售信息：</button>
        <table class="layui-table" lay-size="sm">
            <colgroup>
                <col width="150">
                <col>
            </colgroup>
            <thead>
            <tr class="tr-specInfo-key">
                <th>属性名称</th>
                <th>属性赋值</th>
            </tr>
            </thead>
            <tbody class="tbody-specInfo-value">

            </tbody>
        </table>

        <button type="button" class="layui-btn layui-btn-danger">销售规格：</button>
        <table class="layui-table" lay-size="sm">
            <colgroup>
                <col width="150">
                <col width="200">
                <col width="100">
                <col width="100">
                <col width="100">
            </colgroup>
            <thead>
            <tr class="tr-specInfo-key">
                <th>规格信息</th>
                <th>规格配图</th>
                <th>销售价格</th>
                <th>库存量(件)</th>
                <th>已售量(件)</th>
            </tr>
            </thead>
            <tbody class="tbody-specInfo-msg">
            <!--<tr>-->
                <!--<td>S(建议80-90斤左右)<input type="hidden" name="sku_arr[16][spec_id]" value="16"><input type="hidden"-->
                                                                                                    <!--name="sku_arr[16][spec_name]"-->
                                                                                                    <!--value="S(建议80-90斤左右)">-->
                <!--</td>-->
                <!--<td>-->
                    <!--<input type="number" name="sku_arr[16][selling_price]" value="0.00" required="" class="layui-input">-->
                <!--</td>-->
                <!--<td>-->
                    <!--<input type="number" name="sku_arr[16][stock]" value="0" required="" class="layui-input">-->
                <!--</td>-->
                <!--<td>-->
                    <!--<input type="number" name="sku_arr[16][sold_num]" value="0" required="" class="layui-input">-->
                <!--</td>-->
            <!--</tr>-->
            </tbody>

        </table>
        <input type="hidden" class="attr_info" name="attr_info" value="[]">
    </blockquote>
    <div class="layui-form-item">
        <label class="layui-form-label">库存：</label>
        <div class="layui-input-inline">
            <input type="number" name="stock" readonly
                   value="0" required lay-verify="required"
                   autocomplete="off" class="layui-input input-goods_stock">
        </div>
    </div>
    <div class="layui-form-item layui-form-text ">
        <label class="layui-form-label">商品详情：</label>
        <div class="layui-input-block div-article-content">
            <script id="ue-container" name="details" type="text/plain"></script>
        </div>
    </div>
    {:token()}
    <div class="layui-form-item">
        <div class="layui-input-block div-form-op">
            <button class="layui-btn" type="button" onclick="addGoods()">提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">放弃</button>
        </div>
    </div>
</form>

{/block}

{block name='single-content'}
<script src="__CMS__/js/goods.js"></script>
<script src="__CMS__/js/moZhang.js"></script>
{include file='layouts/ueditor-js'/}
<script>
    var arrSpecFull = [];
    var multiple_images = [];

    //修改按钮的点击事件
    function addGoods() {
        var toUrl = "{:url('cms/goods/add')}";
        var postData = $(".form-opArticle").serialize();
        ToPostPopupsDeal(toUrl, postData);
    }

    layui.use(['form'], function () {
        var form = layui.form;
        form.on('select(toSelCatID)', function (data) {
            //TODO 此时进行ajax的服务器访问，如果返回数据正常，则进行后面代码的调用
            var toUrl = "{:url('cms/specInfo/ajaxGetSpecInfoFstByCat')}";
            goToToSelCatID(toUrl,data,form);
        });
        //点击获取子级属性信息
        form.on('select(toSelSpecFst)', function (data) {
            //TODO 此时进行ajax的服务器访问，如果返回数据正常，则进行后面代码的调用
            var toUrl = "{:url('cms/specInfo/ajaxGetSpecInfoBySpecFst')}";
            goToToSelSpecFst(toUrl,data,form);
        });

        form.on('checkbox(cbSpecInfo)', function (data) {
            goToCbSpecInfo(data);
        });
    });
</script>
{/block}
